/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.openmath.jome.model;

/**
 *
 * @author Mr.Sam
 */
public class KaryOperator extends NaryOperator2 {
    /**
    * The arity of the operator. (in fact the number max of operands the operator must have)
    */
    private int operatorArity;
    
    /**
    * Sets the operator arity
    */
    public void setOperatorArity(int operatorArity) {
        this.operatorArity = operatorArity;
    }
    
    /**
    * Returns the operator arity
    */
    public int getOperatorArity() {
        return operatorArity;
    }
    
    /**
    * Adds a new element (template) to the end of the list.
    * Returns the new element.
    */
    public FormulaTreeStructure addElement() {
        if (getNbChildren() < operatorArity)
            return super.addElement();
        else 
            return this;
        // faudra faire des exceptions pour dire que l'arité n'est pas respéctée
    }
    
    // *****************************************
    // Implémentation de l'interface Modifiable
    
    /**
    * Sets the value.
    */
    public void setValue(String value) {
        setTheOperator(value + "(");
    }
    
    /**
    * Returns the value.
    */
    public String getValue() {
        return getTheOperator();
    }
    
    // *** Fin de l'interface Modifiable ***
    // *************************************
}
